<template>
	<view class="configmessage">
		<view class="selectItem" @click="handleTransfercenter">
			<view class="lable">
				代收中转中心
			</view>
			<view class="content">
				<view class="">
					{{dName==''?'请选择':dName}}
				</view>
				<image :src="imaurl+'b8.png'" style="width: 32rpx;height: 32rpx;" mode=""></image>
			</view>
		</view>
		<view class="selectItem" @click="handleShanty">
			<view class="lable">
				公棚
			</view>
			<view class="content">
				<view class="">
					{{gName==''?'请选择':gName}}
				</view>
				<image :src="imaurl+'b8.png'" style="width: 32rpx;height: 32rpx;" mode=""></image>
			</view>
		</view>


		<view class="enterMessage">
			<view class="title">
				<view class="shu"></view>
				<view class="">
					鸽子信息
				</view>
			</view>

			<view class="itemBox">
				<view class="message" style="">
					<view class="lable">
						环号
					</view>
					<view class="inputitem" style="width: 280rpx;padding-top: 20rpx;">
						{{pageData.ring}}
					</view>
					<!-- <input class="inputitem" v-model="pageData.ring" type="text" placeholder="请输入" /> -->
				</view>
				<view class="message" style="">
					<view class="lable">
						羽色
					</view>
					<view class="inputitem" style="width: 220rpx;padding-top: 20rpx;">
						{{pageData.color}}
					</view>
					<!-- <input class="inputitem" v-model="pageData.color" type="text" placeholder="请输入" /> -->
				</view>
			</view>
			<view class="itemBox">
				<view class="message">
					<view class="lable">
						其他
					</view>
					<textarea class="textareaitem" v-model="pageData.other" cols="30" rows="10"
						placeholder="请输入"></textarea>
				</view>
			</view>

		</view>


		<view class="addressContent">
			<view class="title">
				<view class="shu"></view>
				<view class="">
					我的地址
				</view>
			</view>

			<view class="address">
				<view class="left">
					<view class="left_top">
						<text>{{addressData.realname}}</text> <text>{{addressData.contact_information}}</text>
					</view>
					<view class="sddresstext">
						{{addressData.address}}
					</view>
				</view>
				<view class="right">
					<image :src="imaurl+'a9.png'" style="width: 24rpx;height: 24rpx;" mode=""></image>
					<view class="">
						编辑
					</view>
				</view>

			</view>


		</view>

		<view class="btns" @click="$u.debounce(handleSubmit, 1000)">
			立即提交
		</view>

	</view>
</template>

<script>
	import {
		MyIndex,
		submitsendorder
	} from "@/api/api.js"
	export default {
		data() {
			return {
				pageData: {},
				addressData: {},
				did: "",
				dName: "",
				gid: "",
				gName: "",
				imaurl: "https://szgb.tongchengbang.cc/img/image/",
			}
		},
		onShow() {
			// uni.$once('dData', function(data) {
			// 	console.log('中转中心', JSON.parse(data.ddata));
			// 	this.dName = JSON.parse(data.ddata).dName
			// this.did = JSON.parse(data.ddata).did
			// })
			if (uni.getStorageSync('dData')) {
				this.dName = uni.getStorageSync('dData').dName
				this.did = uni.getStorageSync('dData').did
			}
			if (uni.getStorageSync('gData')) {
				this.gName = uni.getStorageSync('gData').gName
				this.gid = uni.getStorageSync('gData').gid
			}
		},
		onLoad(options) {
			this.pageData = JSON.parse(options.data)
			this.handleMyIndex()
			console.log("options", this.pageData)
		},
		methods: {
			async handleMyIndex() {
				let res = await MyIndex()
				this.addressData = res.data
			},
			handleTransfercenter() {
				uni.navigateTo({
					url: "./transferCenter"
				})
			},
			handleShanty() {
				uni.navigateTo({
					url: "./shanty"
				})
			},
			async handleSubmit() {
				let data = {
					did: this.did,
					gid: this.gid,
					ring: this.pageData.ring,
					color: this.pageData.color,
					other: this.pageData.other
				}
				// console.log("data", data)
				let res = await submitsendorder(data)
				if (res.code == 1) {
					uni.removeStorageSync('dData')
					uni.removeStorageSync('gData')
					uni.showToast({
						title: res.msg,
						icon: "none",
						duration: 1800 
					});
					setTimeout(() => {
						uni.redirectTo({
							url: "./submitSuccessfully"
						})
					}, 2000)
				} else {
					uni.showToast({
						title: res.msg,
						icon: "none",
						duration: 1800
					});
				}

			},
		}
	}
</script>

<style scoped lang="scss">
	.configmessage {
		.selectItem {
			display: flex;
			align-items: center;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 32rpx;
			color: #999999;
			line-height: 42rpx;
			width: 750rpx;
			height: 124rpx;
			background: #FFFFFF;
			margin-top: 1rpx;
			padding: 30rpx 40rpx;
			box-sizing: border-box;
			justify-content: space-between;

			.lable {
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #333333;
				line-height: 38rpx;
			}

			.content {
				display: flex;
				align-items: center;
			}
		}

		.title {
			display: flex;
			font-family: PingFang SC,
				PingFang SC;
			font-weight: 800;
			font-size: 32rpx;
			color: #333333;
			line-height: 38rpx;
			padding: 36rpx 30rpx;
			box-sizing: border-box;
			align-items: center;

			.shu {
				width: 8rpx;
				height: 32rpx;
				background: #00BF52;
				border-radius: 200rpx 200rpx 200rpx 200rpx;
				margin-right: 20rpx;
			}


		}


		.enterMessage {
			width: 750rpx;
			background: #FFFFFF;
			padding-bottom: 30rpx;
			box-sizing: border-box;
			margin-top: 20rpx;

			.itemBox {
				width: 100%;
				display: flex;
				align-items: center;
				padding: 30rpx;
				padding-top: 0;
				box-sizing: border-box;
				justify-content: space-between;

				.message {
					// width: 330rpx;
					display: flex;
					align-items: center;


					.lable {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						color: #333333;
						line-height: 33rpx;
					}

					.inputitem {
						width: 254rpx;
						height: 80rpx;
						background: #F6F6F6;
						border-radius: 20rpx 20rpx 20rpx 20rpx;
						padding-left: 20rpx;
						box-sizing: border-box;
						margin-left: 20rpx;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						line-height: 33rpx;
					}

					.textareaitem {
						width: 614rpx;
						height: 120rpx;
						background: #F6F6F6;
						border-radius: 20rpx 20rpx 20rpx 20rpx;
						margin-left: 20rpx;
						padding: 20rpx;
						box-sizing: border-box;
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 28rpx;
						line-height: 33rpx;
					}
				}
			}

			.btns {
				width: 630rpx;
				height: 88rpx;
				background: #00BF52;
				border-radius: 200rpx 200rpx 200rpx 200rpx;
				font-family: PingFang SC, PingFang SC;
				font-weight: 400;
				font-size: 32rpx;
				color: #FFFFFF;
				line-height: 88rpx;
				text-align: center;
				margin: 0rpx auto;
				margin-top: 30rpx;
			}
		}

		.addressContent {
			width: 750rpx;
			height: 254rpx;
			background: #FFFFFF;
			margin-top: 20rpx;

			.address {
				width: 100%;
				padding: 0 30rpx;
				box-sizing: border-box;
				display: flex;
				align-items: center;
				justify-content: space-between;

				.left {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 28rpx;
					color: #333333;
					line-height: 33rpx;
					width: 584rpx;

					.left_top {
						display: flex;
						align-items: center;
					}

					.sddresstext {
						font-family: PingFang SC, PingFang SC;
						font-weight: 400;
						font-size: 24rpx;
						color: #666666;
						line-height: 28rpx;
						margin-top: 12rpx;
					}
				}

				.right {
					font-family: PingFang SC, PingFang SC;
					font-weight: 400;
					font-size: 24rpx;
					color: #999999;
					line-height: 28rpx;
					display: flex;
					align-items: center;
				}
			}
		}

		.btns {
			width: 630rpx;
			height: 88rpx;
			background: #00BF52;
			border-radius: 200rpx 200rpx 200rpx 200rpx;
			font-family: PingFang SC, PingFang SC;
			font-weight: 400;
			font-size: 32rpx;
			color: #FFFFFF;
			line-height: 88rpx;
			text-align: center;
			margin: 0 auto;
			margin-top: 100rpx;
		}
	}
</style>